//
//  MSSelectProjectViewController.m
//  SocietySale
//
//  Created by Mike on 16/11/17.
//  Copyright © 2016年 Mike. All rights reserved.
//

#import "MSSelectProjectViewController.h"
#import "MSSelectProjectTableVC.h"
#import "MSSearchProjectViewController.h"

@interface MSSelectProjectViewController ()
@property (nonatomic, strong) UIButton               *searchBtn;
@property (nonatomic, strong) MSSelectProjectTableVC *tableVC;
@end

@implementation MSSelectProjectViewController

- (void)initNavigationBar{
    [super initNavigationBar];
    titleLable.text = @"选择项目";
    leftBarBtn.hidden = NO;
}

- (void)initUI{
    self.tableVC = [[MSSelectProjectTableVC alloc] initWithStyle:UITableViewStyleGrouped];
    self.tableVC.view.frame = self.contentView.bounds;
    self.tableVC.enableRefresh = NO;
    self.tableVC.enableRequest = NO;
    self.tableVC.delegate = (id)self;
    self.tableVC.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.contentView addSubview:self.tableVC.view];
    
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 70, SCREENFRAME.size.width, 50)];
    bgView.backgroundColor = kDefaultViewBackgroundColor;
    self.tableVC.tableView.tableHeaderView = bgView;
    
    self.searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.searchBtn.frame = CGRectMake(12, 10, SCREEN_WIDTH-24, 30);
    self.searchBtn.titleLabel.font = HeitiFont(13);
    [self.searchBtn setImage:[UIImage imageNamed:@"search"] forState:UIControlStateNormal];
    [self.searchBtn setTitle:@" 请输入项目名查找项目" forState:UIControlStateNormal];
    [self.searchBtn setTitleColor:kDarkGrayColor forState:UIControlStateNormal];
    self.searchBtn.layer.borderColor = kNormalGray.CGColor;
    self.searchBtn.layer.borderWidth = 0.6;
    self.searchBtn.layer.cornerRadius = 2;
    self.searchBtn.backgroundColor = [UIColor whiteColor];
    [self.searchBtn addTarget:self action:@selector(searchBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:self.searchBtn];
    
}

- (void)testDataFunc{
    self.tableVC.dataArray = [NSMutableArray arrayWithArray:
                              @[[DOKeyValue key:@"从我关注的项目选择" value:@""],
                                [DOKeyValue key:@"从我跟踪的项目选择" value:@""],
                                ]
                              ];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        MSMyAttentionViewController *vc = [[MSMyAttentionViewController alloc] init];
        vc.isCreatProject = YES;
        [rootNavigation pushViewController:vc animated:YES];
    }
    if (indexPath.section == 1) {
        MSMyFollowViewController *vc = [[MSMyFollowViewController alloc] init];
        vc.projectType = MSProjectType_CreatProject;
        [rootNavigation pushViewController:vc animated:YES];
    }
}

- (void)searchBtnClick{
    MSSearchProjectViewController *vc = [[MSSearchProjectViewController alloc] init];
    [rootNavigation pushViewController:vc animated:YES];
}

@end
